import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:kkhousekeep/widget/custom_form_selection.dart';

class CustomTable extends Table {
  CustomTable({super.key, super.children})
      : super(
          defaultVerticalAlignment: TableCellVerticalAlignment.middle,
          border: TableBorder(
              horizontalInside:
                  BorderSide(color: const Color(0xFFf4f5f6), width: 2.h)),
          columnWidths: const {
            0: IntrinsicColumnWidth(),
            1: FlexColumnWidth(),
          },
        );

  static Widget buildFormTitle(String title, {bool? isRequired}) {
    return Padding(
        padding: EdgeInsets.only(top: 30.h, bottom: 30.h),
        child: Row(
          children: [
            Visibility(
              maintainAnimation: true,
              maintainState: true,
              maintainSize: true,
              visible: isRequired ?? false,
              child: SizedBox(
                width: 32.w,
                child: Text(
                  "*",
                  textAlign: TextAlign.end,
                  style: TextStyle(
                    fontSize: 32.sp,
                    color: const Color(
                      0xFFDD5045,
                    ),
                  ),
                ),
              ),
            ),
            Text(
              title,
              style: TextStyle(
                fontSize: 32.sp,
                color: const Color(
                  0xFF6D6D6D,
                ),
              ),
            ),
          ],
        ));
  }

  static Widget buildFormContent(String content) {
    return Text(
      content,
      style: TextStyle(
        fontSize: 32.sp,
        color: const Color(0xFF333333),
      ),
    );
  }

  static buildSelection({
    bool? enable,
    String? text,
    String? hintText,
    GestureTapCallback? onTap,
  }) {
    return CustomFormSelection(
      enable: enable ?? true,
      text: text,
      hintText: hintText,
      onTap: onTap,
    );
  }
}
